package com.fzz.learning_forum.serviceImpl;

import com.fzz.learning_forum.dao.ReplyMapping;
import com.fzz.learning_forum.domain.Reply;
import com.fzz.learning_forum.service.ReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Component
public class ReplyServiceImpl implements ReplyService {

    @Autowired
    private ReplyMapping replyMapping;

    //发表回复
    @Override
    public Integer publishReply(Reply reply) {

        Date date=new Date();
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        simpleDateFormat.format(date);
        reply.setCreated(date);
        return replyMapping.publishReply(reply);
    }

    //查询回复
    @Override
    public List<Reply> selectReply(Integer article_id) {
        return replyMapping.selectReply(article_id);
    }
}
